package com.demo.web.controllers;

import com.demo.service.FlowTestService;
import org.activiti.engine.repository.ProcessDefinition;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Get;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;

import java.util.List;

@Controller
@Mapping(value = "/flow/test")
public class FlowTestController {

    @Inject
    FlowTestService flowTestService;

    //测试获取模板列表
    @Get
    @Mapping(value = "/template/list")
    public List<ProcessDefinition> getTemplateList() throws Exception {
        return flowTestService.getTemplateList();
    }

    //测试发起流程
    @Get
    @Mapping(value = "/testStartFlowSuccess")
    public String testStartFlowSuccess() throws Exception {
        flowTestService.testStartFlowSuccess();
        return "ok";
    }

    //测试发起流程后同一事务的回滚
    @Get
    @Mapping(value = "/testStartFlowError")
    public String testStartFlowError() throws Exception {
        flowTestService.testStartFlowError();
        return "ok";
    }
}
